﻿<%@ Page MasterPageFile="~/Site1.Master" Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="DigDes.DSchool.SUPS.Web.UI.WebForm2" EnableEventValidation="false"%>

    <asp:Content ID="Content1" ContentPlaceHolderID="web1" runat="server">
       
        <br/><br/>
       
       
       
                 <asp:GridView ID="GridView1" runat="server" CssClass="wf2GV" AutoGenerateColumns="False"  DataSourceID="ObjectDataSource1"  OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="ID" OnRowDataBound="GridView1_RowDataBound"  OnPageIndexChanging="GridView1_PageIndexChanging"  AllowPaging="true" PageSize="10" >
                     
                     <Columns>
                           <asp:BoundField DataField="ID" Visible="false" />
                           <asp:BoundField DataField="Name" HeaderText="Наименование" SortExpression="Name" HeaderStyle-CssClass="nameGV" ItemStyle-CssClass="nameGV">
<HeaderStyle CssClass="nameGV"></HeaderStyle>

<ItemStyle CssClass="nameGV"></ItemStyle>
                           </asp:BoundField>
                           <asp:BoundField DataField="Description" HeaderText="Описание" SortExpression="Description" HeaderStyle-CssClass="descGV" ItemStyle-CssClass="descGV">
<HeaderStyle CssClass="descGV"></HeaderStyle>

<ItemStyle CssClass="descGV"></ItemStyle>
                           </asp:BoundField>
                           <asp:BoundField DataField="Code" HeaderText="Код" SortExpression="Code" HeaderStyle-CssClass="codeGV" ItemStyle-CssClass="asd">
<HeaderStyle CssClass="codeGV"></HeaderStyle>

<ItemStyle CssClass="asd"></ItemStyle>
                           </asp:BoundField>
                           <asp:BoundField DataField="Mnemocode" HeaderText="Мнемокод" SortExpression="Mnemocode"  HeaderStyle-CssClass="mnemGV" ItemStyle-CssClass="mnemGV">
<HeaderStyle CssClass="mnemGV"></HeaderStyle>

<ItemStyle CssClass="mnemGV"></ItemStyle>
                           </asp:BoundField>
                           <asp:CheckBoxField DataField="IsUsed" HeaderText="Используется" SortExpression="IsUsed" HeaderStyle-CssClass="usedGV" ItemStyle-CssClass="tdCenter">
<HeaderStyle CssClass="usedGV"></HeaderStyle>

<ItemStyle CssClass="tdCenter"></ItemStyle>
                           </asp:CheckBoxField>
                           <asp:CheckBoxField DataField="IsEmpty" HeaderText="Порожний" SortExpression="IsEmpty" HeaderStyle-CssClass="emptyGV" ItemStyle-CssClass="tdCenter">
<HeaderStyle CssClass="emptyGV"></HeaderStyle>

<ItemStyle CssClass="tdCenter"></ItemStyle>
                           </asp:CheckBoxField>
                           <asp:ImageField dataimageurlfield="ID" HeaderText="Изображение"   dataimageurlformatstring="~\CargoImage.ashx?ID={0}"  ControlStyle-CssClass="imgdb" >
<ControlStyle CssClass="imgdb"></ControlStyle>
                           </asp:ImageField>
                     </Columns>
                       <SelectedRowStyle BackColor="#99CCFF" />
                </asp:GridView>
       
         
        <asp:ObjectDataSource ID="ObjectDataSource1"  runat="server" EnablePaging="true" SelectCountMethod="SelectCount" SelectMethod="SelectPage"  TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoDAC" DataObjectTypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoRows" OnSelecting="ObjectDataSource1_Selecting" UpdateMethod="Update" MaximumRowsParameterName="MaxRow"
                              StartRowIndexParameterName="StartRow"  >
            
        </asp:ObjectDataSource>
        <br/>
        
      
        <asp:Button ID="Add_Button" runat="server" Text="Добавить" OnClick="btAdd_Click" CssClass="button" />&nbsp;&nbsp;
        <asp:Button ID="Edit_Button" runat="server" Text="Изменить" OnClick="btEdit_Click" Visible=" false" CssClass="button" />&nbsp;&nbsp;
        <asp:Button ID="Delete_Button" runat="server" Text="Удалить" OnClick="btDelete_Click" Visible="false" CssClass="button" />&nbsp;&nbsp;
        
        <br/>
        <asp:Label ID="infLabel" CssClass="infLabel" Visible="false" runat="server"></asp:Label>
        <br/>
        
        <asp:DetailsView ID="DetailsView1" CssClass="wf2DV" visible="False" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource2"  OnItemInserting="DetailsView1_ItemInserting" OnPreRender="DetailsView1_PreRender" DataKeyNames="ID" OnItemUpdating="DetailsView1_ItemUpdating" >
            <Fields>
                
                
                <asp:BoundField DataField="ID" SortExpression="ID" Visible="false" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Наименование</label>
                    </ItemTemplate>
                </asp:TemplateField>               
                <asp:BoundField DataField="Name" SortExpression="Name" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Описание</label>
                    </ItemTemplate>
                </asp:TemplateField>   
                <asp:BoundField DataField="Description" SortExpression="Description" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Код</label>
                        
                    </ItemTemplate>
                </asp:TemplateField>   
                <asp:BoundField DataField="Code"  SortExpression="Code" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Мнемокод</label>
                    </ItemTemplate>
                </asp:TemplateField>   
                <asp:BoundField DataField="Mnemocode" SortExpression="Mnemocode" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Используется</label>
                    </ItemTemplate>
                </asp:TemplateField>   
                <asp:CheckBoxField DataField="IsUsed"  SortExpression="IsUsed" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <label class="dv_labels">Порожний</label>
                    </ItemTemplate>
                </asp:TemplateField>   
                <asp:CheckBoxField DataField="IsEmpty"  SortExpression="IsEmpty" />
                <asp:TemplateField >
                      <EditItemTemplate>
                          <label class="dv_labels">Вставить изображение:</label>
                          <asp:FileUpload ID="FileUpload1" runat="server" />
                          </EditItemTemplate>
                      <InsertItemTemplate>
                          <label class="dv_labels">Вставить изображение:</label>
                          <asp:FileUpload ID="FileUpload1" runat="server" />
                          
                      </InsertItemTemplate>
                
                </asp:TemplateField>
                <asp:BoundField DataField="Data" SortExpression="Data" Visible="false"/>                      
                
                
                
            </Fields>
        </asp:DetailsView>
            
        
        <asp:Button ID="Save_Button" runat="server" Text="Сохранить" Visible="false" OnClick="Save_Button_Click" CssClass="svbutton" />&nbsp;&nbsp;
        <asp:Button ID="Cancel_Button" runat="server" Text="Отмена" Visible="false" OnClick="Cancel_Button_Click" CssClass="button" />
         
        <br/>
        <asp:ObjectDataSource ID="ObjectDataSource2"  
                              runat="server"
                              SelectMethod="SelectRow" 
                              TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoDAC" 
                              
                              UpdateMethod ="Update1" 
                              DeleteMethod="Delete" 
                              InsertMethod="Insert1" 
                              >
            
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Code" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
                <asp:Parameter Name="IsUsed" Type="Boolean" />
                <asp:Parameter Name="IsEmpty" Type="Boolean" />
                
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Code" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
                <asp:Parameter Name="IsUsed" Type="Boolean" />
                <asp:Parameter Name="IsEmpty" Type="Boolean" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
             <DeleteParameters>
                 <asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
             </DeleteParameters>
        </asp:ObjectDataSource>
        
  </asp:Content>